import 'package:dio/dio.dart';


class OneSentence{
  final dio = Dio();

  Future<String?> getSentence() async{
    try {
      final response = await dio.get('https://60s-api.viki.moe/v2/hitokoto');

      if (response.statusCode == 200) {
        // 解析JSON
        Map<String, dynamic> jsonData = response.data['data'];

        // 只需要特定字段
        String hitokoto = jsonData['hitokoto'];

        return hitokoto;
      }
    } catch (e) {
      print('网络请求失败: $e');
      return "无法获取任何数据";
    }
    return null;
  }

}